var gulp=require('gulp');
var connect=require('gulp-connect');
var gulpif=require('gulp-if');
var open=require('gulp-open');
var del=require('del');
var sequence=require('gulp-sequence');

var test=require('./tasks/test');
var develop=require('./tasks/develop');
var compile=require('./tasks/compile');
var release=require('./tasks/release');

gulp.task('clean',function(){
    return del([
        'dist/*',
        'dist/**/*'
    ]);
});

gulp.task('server:start', function () {
    connect.server({
        port:8080,
        livereload: false
    });
});

gulp.task('server',['server:start'], function () {
    return gulp.src('dist/release/index.html')
        .pipe(open({
            uri: 'http://127.0.0.1:8080/dist/release/index.html'
        }));
});

gulp.task('default', sequence(
    'clean','compile:lib','compile:app','release'//,'server'
));

gulp.task('develop', sequence(
    'clean','develop:lib','develop:app','release'//,'server'
));